package com.marktotop.file.exception;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author WXLD
 * @data 2021/4/16 - 12:14
 */
@Data
public class SystemException extends Exception implements BaseError{


    /**
     * 错误码
     */
    private int errorCode;
    /**
     * 错误信息
     */
    private String errorMsg;


    @Override
    public int getResultCode() {
        return errorCode;
    }

    @Override
    public String getResultMsg() {
        return errorMsg;
    }


    /**
     * 使用自定义的异常枚举类构造异常
     * @param baseError
     */
    public SystemException(BaseError baseError){
        this.errorCode = baseError.getResultCode();
        this.errorMsg = baseError.getResultMsg();
    }

    public SystemException(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public SystemException(int errorCode) {
        this.errorCode = errorCode;
        this.errorMsg = "未知错误！！！";
    }

    public SystemException(String errorMsg) {
        this.errorCode = 10001;
        this.errorMsg = errorMsg;
    }
}
